package com.zhc.sandbox;

public class SandBox {
    static {
        System.load(System.getProperty("user.dir") + "/sandbox-server/src/main/java/com/zhc/sandbox/c/exec.so");
    }

    public static native Result exec(Config config);

    public static void main(String[] args) {
        Config config = new Config();
        config.setInputPath("/root/java/zoj/sandbox-server/src/main/resources/data/in.txt");
        config.setOutputPath("/root/java/zoj/sandbox-server/src/main/resources/data/out.txt");
        config.setErrorPath("/root/java/zoj/sandbox-server/src/main/resources/data/err.txt");
        config.setExeType(1);
        config.setExePath("/home/parallels/Desktop/linux-jdk8/jdk1.8.0_411/bin/java");
        config.setExeArgs(new String[]{"java", "-cp", "/root/java/zoj/sandbox-server/src/main/resources/demo/", "Main"});
        config.setExeEnvs(new String[]{null});
        config.setMaxCpuTime(2);
        config.setMaxRealTime(2);
        config.setMaxMemory(40000000000L);  // 4 GB
        config.setMaxOutputSize(99999999);  // 4 MB
        config.setMaxProcessNumber(99999999);
        config.setMaxStackSize(99999999);
        Result result = exec(config);
        System.out.println(result);
    }
}